package cn.gdust.utils;

import java.sql.Connection;
import java.sql.DriverManager;
//http://localhost:8080/img/recommend1.png
public class DB {
    /**打开一个数据库连接，如果连接失败，返回null*/
    public static Connection open() {
        try {
            //1.加载驱动程序
            Class.forName("com.mysql.cj.jdbc.Driver");
            //2.填写连接参数，获取连接对象
            return DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/videoDB?serverTimezone=UTC"
                    , "root", "zhan0420");
        }catch(Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public static void main(String[] args) {
        System.out.println(DB.open());
    }
}
